<!--
 * @otherInfoription: 代表性教师基本情况
 * @Autor:  'AgoniLay'
 * @Date: 2021-10-08 17:02:22
 * @LastEditTime: 2021-10-09 17:12:56
 * @FilePath: \subject-evaluation\src\views\page\2-2-2.vue
-->
<template>
  <div class="II-II-II">
    <table class="II-II-II__table">
      <tr class="II-II-II__table-trone">
        <td class="II-II-II__table-trone-td"
            colspan="13">
          <div class="II-II-II__table-trone-td-title">
            II-2-2 代表性教师基本情况
            <span class="II-II-II__table-trone-td-title-tips">
              【生物工程、网络空间安全学科限15人，其他学科限20人】（45岁以下青年教师人数不少于 1/3）
            </span>
          </div>
        </td>
        <el-button type="success"
                   size="small"
                   icon="el-icon-plus"
                   class="II-II-II__table-trone-add-button"
                   @click.prevent="addItem">
          添加方向
        </el-button>
      </tr>
      <template v-for="(item, index) in bbbs">
        <tr :key="index"
            class="II-II-II__table-trtwo">
          <td class="II-II-II__table-trtwo-tdone"
              colspan="3">
            学科方向{{ index + 1 }}
          </td>
          <td class="II-II-II__table-trtwo-tdtwo"
              colspan="7">
            <el-input v-model="item.discipDirect"
                      class="II-II-II__table-trtwo-tdtwo-input"
                      autosize
                      type="textarea"/>
          </td>
          <td class="II-II-II__table-trtwo-tdthree">
            专任教师数
          </td>
          <td class="II-II-II__table-trtwo-tdfour">
            <el-input v-model="item.fullTimeTeacherNum"
                      class="II-II-II__table-trtwo-tdfour-input"
                      type="number"/>
          </td>
          <td class="II-II-II__table-trtwo-tdfive">
            正高级职称数
          </td>
          <td class="II-II-II__table-trtwo-tdsix">
            <el-input v-model="item.seniorNum"
                      class="II-II-II__table-trtwo-tdsix-input"
                      type="number"/>
          </td>
          <el-button type="danger"
                     size="small"
                     icon="el-icon-delete"
                     class="II-II-II__table-th-delete-button"
                     @click.prevent="deleteSubject(index)">
            删除本方向
          </el-button>
        </tr>
        <tr :key="index + '$'"
            class="II-II-II__table-th">
          <td class="II-II-II__table-th-tdone">
            序号
          </td>
          <td class="II-II-II__table-th-tdtwo">
            姓名
          </td>
          <td class="II-II-II__table-th-tdthree">
            年龄
          </td>
          <td class="II-II-II__table-th-tdfour">
            专业技术职务
          </td>
          <td class="II-II-II__table-th-tdfive">
            导师<br>类别
          </td>
          <td class="II-II-II__table-th-tdsix">
            最高<br>学位
          </td>
          <td class="II-II-II__table-th-tdseven">
            本单位<br>工作年限
          </td>
          <td class="II-II-II__table-th-tdeight">
            年均<br>课时数
          </td>
          <td class="II-II-II__table-th-tdnine">
            主要研究方向
          </td>
          <td class="II-II-II__table-th-tdten">
            是否第一学科
          </td>
          <td class="II-II-II__table-th-tdeleven">
            国内外重要学术<br>组织任职
          </td>
          <td class="II-II-II__table-th-tdtwelve"
              colspan="3">
            其他情况简介
            <span class="II-II-II__table-th-tdeight-tips">
              （限 50 字）
            </span>
          </td>
          <el-button type="success"
                     size="small"
                     icon="el-icon-plus"
                     class="II-II-II__table-th-add-button"
                     circle
                     @click.prevent="addItem(index)"/>
        </tr>
        <tr v-for="(i, idx) in item.teachInfos"
            :key="index + '' + idx"
            class="II-II-II__table-trother">
          <td class="II-II-II__table-trother-tdone">
            {{ idx + 1 }}
          </td>
          <td class="II-II-II__table-trother-tdtwo">
            <el-input v-model="i.name"
                      class="II-II-II__table-trother-tdtwo-input"
                      autosize
                      placeholder="张三"
                      type="textarea"/>
          </td>
          <td class="II-II-II__table-trother-tdthree">
            <el-input v-model="i.age"
                      class="II-II-II__table-trother-tdthree-input"
                      placeholder="54"
                      type="number"/>
          </td>
          <td class="II-II-II__table-trother-tdfour">
            <el-input v-model="i.origPosition"
                      class="II-II-II__table-trother-tdfour-input"
                      placeholder="正高级"
                      autosize
                      type="textarea"/>
          </td>
          <td class="II-II-II__table-trother-tdfive">
            <el-input v-model="i.tutorCategoty"
                      class="II-II-II__table-trother-tdfive-input"
                      autosize
                      placeholder="博导"
                      type="textarea"/>
          </td>
          <td class="II-II-II__table-trother-tdsix">
            <el-input v-model="i.highestDegree"
                      class="II-II-II__table-trother-tdsix-input"
                      autosize
                      placeholder="博士"
                      type="textarea"/>
          </td>
          <td class="II-II-II__table-trother-tdseven">
            <el-input v-model="i.workYear"
                      class="II-II-II__table-trother-tdseven-input"
                      placeholder="5"
                      type="number"/>
          </td>
          <td class="II-II-II__table-trother-tdeight">
            <el-input v-model="i.avgClassHour"
                      class="II-II-II__table-trother-tdeight-input"
                      placeholder="32"
                      type="number"/>
          </td>
          <td class="II-II-II__table-trother-tdnine">
            <el-input v-model="i.researchDirection"
                      class="II-II-II__table-trother-tdnine-input"
                      autosize
                      placeholder="XXXXXX"
                      type="textarea"/>
          </td>
          <td class="II-II-II__table-trother-tdten">
            <el-input v-model="i.firstDiscipline"
                      class="II-II-II__table-trother-tdten-input"
                      placeholder="是"
                      type="text"/>
          </td>
          <td class="II-II-II__table-trother-tdeleven">
            <el-input v-model="i.post"
                      class="II-II-II__table-trother-tdeleven-input"
                      autosize
                      placeholder="中国XX学会理事长"
                      type="textarea"/>
          </td>
          <td class="II-II-II__table-trother-tdtwelve"
              colspan="3">
            <el-input v-model="i.otherInfo"
                      type="textarea"
                      :autosize="{ minRows:2 }"
                      maxlength="50"
                      showWordLimit
                      class="II-II-II__table-trother-tdtwelve-textarea"/>
          </td>
          <el-button type="danger"
                     size="small"
                     icon="el-icon-delete"
                     class="II-II-II__table-trother-delete-button"
                     circle
                     @click.prevent="deleteSubjectItem(index, idx)"/>
        </tr>
      </template>
    </table>
    <div class="II-II-II__explain">
      <span class="II-II-II__explain-strong">
        说明：①
      </span>
      代表性教师按学科方向填写，学科方向不限于“二级学科”，按本校学科建设的实际情况填写。
      <span class="II-II-II__explain-strong">
        ②
      </span>
      代表性教师应是表II-2-1表（一）中界定的“专任教师”，且评估期内在本学科招收过研究生。
      <span class="II-II-II__explain-strong">
        ③
      </span>
      跨学科人员评估期内在两个学科均招收过研究生，可在两个学科填写，但应在“是否第一学科”中注明。
      <span class="II-II-II__explain-strong">
        ④
      </span>
      “年均课时数”仅统计评估期内给本科生和研究生按培养计划开设并计入学分的各类课程。
      <span class="II-II-II__explain-strong">
        ⑤
      </span>
      同一教师有多个“国内外重要学术组织任职”时，最多填写两项。
      <span class="II-II-II__explain-strong">
        ⑥
      </span>
      教师在评估期内获得重要荣誉称号、在重要期刊或社会组织担任职务等，可在“其他情况简介”栏中填写。
    </div>
  </div>
</template>

<script>
import { getPageData } from '@/utils/getData.js'

export default {
  watch: {
    bbbs: {
      handler (newVal) {
        sessionStorage['this_data'] = JSON.stringify(newVal)
      },
      deep: true,
      immediate: true
    }
  },
  async mounted () {
    const loading = this.$loading({ lock: true, text: '数据获取中...请稍后！', background: 'rgba(0, 0, 0, 0.7)' })
    this.bbbs = await getPageData('bbbs')
    loading.close()
  },
  data () {
    return {
      bbbs: [
        { discipDirect: '', fullTimeTeacherNum: '', seniorNum: '', teachInfos: [{ name: '', age: '', origPosition: '', tutorCategoty: '', highestDegree: '', workYear: '', avgClassHour: '', firstDiscipline: '', researchDirection: '', post: '', otherInfo: '' }] }
      ]
    }
  },
  methods: {
    addItem (index) {
      if (typeof index === 'number') {
        var count = 20
        if (this.bbbs[index].discipDirect === '生物工程' || this.bbbs[index].discipDirect === '网络空间安全学科') count = 15
        if (this.bbbs[index].teachInfos.length < count) {
          this.bbbs[index].teachInfos.push({ name: '', age: '', origPosition: '', tutorCategoty: '', highestDegree: '', workYear: '', avgClassHour: '', firstDiscipline: '', researchDirection: '', post: '', otherInfo: '' })
        }
      } else {
        this.bbbs.push({ discipDirect: '', fullTimeTeacherNum: '', seniorNum: '', teachInfos: [{ name: '', age: '', origPosition: '', tutorCategoty: '', highestDegree: '', workYear: '', avgClassHour: '', firstDiscipline: '', researchDirection: '', post: '', otherInfo: '' }] })
      }
    },
    deleteSubject (index) {
      if (this.bbbs.length > 1) {
        this.bbbs.splice(index, 1)
      }
    },
    deleteSubjectItem (index, idx) {
      if (this.bbbs[index].teachInfos.length > 1) {
        this.bbbs[index].teachInfos.splice(idx, 1)
      }
    }
  }
}
</script>

<style lang="less" scoped>
@import '../../assets/css/page/2-2-2.less';
</style>
